﻿using BootstrapBlazor.Components;
using BPM.Web.Shared.Data;
using BPM.Web.Shared.Extensions;
using BPM.Web.Shared.Dependencies;
namespace BPM.Web.Shared.Service;

[Scoped(typeof(ISysDictDataService))]
public class SysDictDataService : BaseService, ISysDictDataService
{
    private IDictDataClient _dictDataClient;
    public SysDictDataService(IDictDataClient dictDataClient, ToastService toast) : base(toast)
        => _dictDataClient = dictDataClient;

    public Task<bool> AddAsync(DictDataOutput input)
        => ExecuteAsync(_dictDataClient.AddAsync(input.Adapt<AddDictDataInput>()));

    public Task<bool> DeleteAsync(IEnumerable<DictDataOutput> input)
        => DeleteAsync(input.Adapts<DictDataOutput, DeleteDictDataInput>().Select(x => _dictDataClient.DeleteAsync(x)));

    public Task<QueryData<DictDataOutput>> PageAsync(DictDataPageInput input)
        => QueryAsync(_dictDataClient.PageAsync(input));

    public Task<bool> EditAsync(DictDataOutput input)
        => ExecuteAsync(_dictDataClient.EditAsync(input.Adapt<UpdateDictDataInput>()));
}

